package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;



public class ReflectDemo6 {
    public static void main(String[] args) throws Exception {
        //

        Class cls=Class.forName("reflect.Person");
        Method method=cls.getMethod("say",String.class,int.class);


        String name=method.getName();
        System.out.println("方法的名称："+name);

        Class returnType=method.getReturnType();
        System.out.println("方法的返回值类型"+returnType);

        int count=method.getParameterCount();
        System.out.println("方法的参数个数"+count);

        Class[] parameterTypes=method.getParameterTypes();
        for(Class c:parameterTypes)
        {
            System.out.println("方法的参数类型"+c);
        }

        //获取方法的修饰符
        int modifiers= method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("public");
                break;
            case Modifier.PRIVATE:
                    System.out.println("private");
                    break;
            case Modifier.PROTECTED:
                    System.out.println("protected");
                    break;
            default:
                    System.out.println("default");

        }








    }
}
